home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
PIXELWOR
/
CPIXELWO.C1
< prev
next >
Wrap
Text File
|
1992-01-01
|
27KB
|
938 lines
/******************************************************************************
CPixelWorld.c
Pixel World Class, Version 1.0 (SUPERCLASS = CBitMap)
__________________________________________________________________________
Ñ Description
The CPixelWorld class is a subclass of CBitMap (THINK Class Library 1.1)
designed to maintain a color offscreen drawing environment using the
standard conventions of Color QuickDraw. An offscreen color graphics
device (GDevice) and an offscreen color graphics port (CGrafPort) are
used to maintain this offscreen world. This implementation supports
standard pixel depths of 1,2,4 and 8 bits. Pixel depths of 16 and 32
are not supported since this implementation does not rely on 32-Bit
QuickDraw features. In the future, support for 16 and 32 bit pixel
depths and the offscreen GWorlds provided by 32-Bit QuickDraw can be
incorporated into a subclass of CPixelWorld called CGWorld.
Ñ Creating a Blank Pixel World
A blank pixel world is created by calling the initialization method
IPixelWorld() with a pixel depth (aPixelDepth), a bounds rectangle
(aBoundsRect), a handle to a color table (aColorTable), and NULL for
the handle to the pixel image (aPixelImage). You can pass any value
for row bytes (aRowBytes) since the value will be ignored in this case.
You should pass a color table handle (CTabHandle) in the aColorTable
parameter. The color table is copied and the copy is used for the
offscreen world. If aColorTable is NULL, then the default color table
for the desired pixel depth will be used.
*** WARNING ***
If you request a pixel depth of one and Color QuickDraw is not
available, then a blank offscreen world will be created as a standard
BitMap with a non-color graphics port (GrafPort) using the CBitMap
superclass. If you request a pixel depth greater than one and Color
QuickDraw is not available, the initialization method will fail. To
detect initialization failure call the method WorldIsOK(), which
returns the value of the instance variable worldIsOK. WorldIsOK()
will return TRUE after successful initialization, and FALSE after
initialization failure.
Ñ Creating a Pixel World with an Existing Image
A world based on an existing color or grayscale image is created by
calling the initialization method IPixelWorld() with the pixel depth of
the existing image (aPixelDepth), the bounds rectangle of the existing
image (aBoundsRect), a color table for the existing image (aColorTable),
and a handle to the pixels for the existing image (aPixelImage). In
this case, you must also pass a value for the row bytes of the pixel
image (aRowBytes).
*** IMPORTANT ***
When you create an offscreen world based on an existing pixel image,
IT IS YOUR RESPONSIBILITY TO DISPOSE OF YOUR PIXEL IMAGE. Although
CPixelWorld keeps its own handle to your pixel image in the instance
variable worldPixels, it will not dispose of the pixel image. In
contrast, when you create a blank world by passing NULL for the
aPixelImage parameter, CPixelWorld creates its own pixel image and it
will dispose of this image when the offscreen world is destroyed by
the Dispose() instance method.
When you create your own pixel image for use with an offscreen world
use a multiple of four for the row bytes of your pixel image. The
following formula will give a multiple of four for row bytes:
rowBytes = ((((long) width * pixelDepth) + 31) / 32) * 4;
A multiple of four for row bytes will give optimal performance in calls
to the QuickDraw function CopyBits() and its related functions.
*** WARNING ***
When you create an offscreen world with an existing image that has a
pixel depth greater than one, the initialization method will fail if
Color QuickDraw is not available since there is no support for images
with pixel depths greater than one without Color QuickDraw.
Ñ Drawing to the Offscreen Pixel World
If you need to draw directly to the offscreen world, you must bracket
all drawing with calls to BeginDrawing() and EndDrawing(). This will
set up the offscreen GDevice and CGrafPort for drawing. In addition,
the LockWorld() method will be called to make sure that the pixel
image is anchored down and will not move when you invoke any QuickDraw
routines. LockWorld() locks the handle to the pixel image, and then
it loads the derefernced handle into the PixMap baseAddr pointers of
both the offscreen GDevice and the offscreen CGrafPort.
Ñ Version History
__________________________________________________________
Release Version: 1.0
Release Date: January 1, 1992
Implemented By: Vincent R. Vann, Jr.
1901 Brickell Ave, B-410
Miami, Florida 33129 USA
Compuserve Address: 76530,1242
Internet Address: vvann@umbio.med.miami.edu
(129.171.65.204)
__________________________________________________________
Ñ License Agreement
All portions of this source code are property of Vincent R. Vann, Jr.
I, Vincent R. Vann, Jr., grant you the right to freely distribute this
source code and to use all or part of this source code in all software
including commercial, freeware, shareware and private applications.
However, all software that uses any part of or all of this source code
must display a copyright notice indicating that either all of or
portions of this source code are used in the software. I also grant
you permission to alter and make improvements to this source code, but
only if all modifications are returned to me by whatever means are
available, either in written or electronic form. You must also accept
that I retain the right to include any part of your modifications or
all of your modifications in future releases of this source code. The
description and version history sections above may be ammended for
documentation purposes. This license agreement and the copyright
notice below must be maintained intact and must be included with all
distributions of this source code at all times.
This implementation is based in part on material copyrighted by Apple
Computer, Inc. and Symantec Corporation.
Copyright ⌐ 1992 Vincent R. Vann, Jr. All rights reserved.
******************************************************************************/
#include "CPixelWorld.h"
#include "CDesktop.h"
#include "Exceptions.h"
#include "Global.h"
#include "LongQD.h"
#include "TCLUtilities.h"
/**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
/******************************************************************************
IPixelWorld
Initialize a PixelWorld object
******************************************************************************/
void CPixelWorld::IPixelWorld(
short aPixelDepth, /* Pixel depth of world in bits */
Rect *aBoundsRect, /* Bounds rectangle of world */
CTabHandle aColorTable, /* ColorTable for world image */
Handle aPixelImage, /* Handle to pixel image for world */
short aRowBytes) /* Row bytes of pixel image */
{
/* Initialize instance variables of CBitMap superclass */
macPort = NULL;
savePort = NULL;
macBitMap = NULL;
xferMode = srcCopy;
/* Initialize instance variables of CPixelWorld class */
worldIsOK = FALSE; /* TRUE if initialized successfully */
worldHasColor = gSystem.hasColorQD; /* TRUE if have Color QuickDraw */
worldHas32BitQD = FALSE; /* TRUE if have 32-Bit QuickDraw */
worldOwnsPixels = FALSE; /* TRUE if world owns pixel image */
worldPixelsLocked = FALSE; /* TRUE if pixel image is locked */
worldDepth = 0;
worldBounds.left = 0;
worldBounds.top = 0;
worldBounds.right = 0;
worldBounds.bottom = 0;
worldColors = NULL;
worldDevice = NULL;
worldPort = NULL;
worldPixels = NULL;
saveDevice = NULL;
if (!worldHasColor)
IPixelWorldBW( aPixelDepth, aBoundsRect, aPixelImage, aRowBytes);
else
IPixelWorldColor( aPixelDepth, aBoundsRect, aColorTable, aPixelImage, aRowBytes);
}
/******************************************************************************
IPixelWorldBW
Initialize a black and white pixel world
******************************************************************************/
void CPixelWorld::IPixelWorldBW(
short aPixelDepth, /* Pixel depth of world in bits */
Rect *aBoundsRect, /* Bounds rectangle of world */
Handle aPixelImage, /* Handle to pixel image for world */
short aRowBytes) /* Row bytes of pixel image */
{
GrafPtr theSavedPort;
Boolean theSavedAlloc;
short rowBytes;
long bytes, width, height;
/***
*** Check for a valid pixel depth
***/
if (aPixelDepth != 1) return;
/***
*** Create the offscreen bitmap
***/
width = aBoundsRect->right - aBoundsRect->left;
height = aBoundsRect->bottom - aBoundsRect->top;
if (aPixelImage != NULL && aRowBytes != 0)
rowBytes = aRowBytes;
else
rowBytes = ((width * aPixelDepth + 31) / 32 ) * 4;
bytes = height * rowBytes;
theSavedAlloc = SetAllocation( kAllocCanFail);
macBitMap = (BitMap *) NewPtrClear(sizeof(BitMap) + bytes);
SetAllocation( theSavedAlloc);
FailNIL( macBitMap);
macBitMap->baseAddr = (Ptr) (macBitMap + 1);
macBitMap->rowBytes = rowBytes;
macBitMap->bounds = *aBoundsRect;
/***
*** Copy the existing pixel image into the offscreen bitmap
***/
if (aPixelImage != NULL && aRowBytes != 0)
{
long n;
n = GetHandleSize(aPixelImage);
if (n > 0 && MemError() == noErr)
{
if (n > bytes) n = bytes;
HLock( aPixelImage);
BlockMove( (Ptr) *aPixelImage, macBitMap->baseAddr, n);
HUnlock( aPixelImage);
}
}
/***
*** Create the offscreen graphics port
***/
theSavedAlloc = SetAllocation( kAllocCanFail);
macPort = (GrafPtr) NewPtrClear( sizeof(GrafPort));
SetAllocation( theSavedAlloc);
FailNIL( macPort);
GetPort( &theSavedPort);
OpenPort( macPort);
SetPort( macPort);
SetPortBits( macBitMap);
macPort->portRect = *aBoundsRect;
RectRgn( macPort->visRgn, aBoundsRect);
RectRgn( macPort->clipRgn, aBoundsRect);
SetPort( theSavedPort);
CView::ForceNextPrepare();
worldIsOK = TRUE;
}
/******************************************************************************
IPixelWorldColor
Initialize a color pixel world
******************************************************************************/
void CPixelWorld::IPixelWorldColor(
short aPixelDepth, /* Pixel depth of world in bits */
Rect *aBoundsRect, /* Bounds rectangle of world */
CTabHandle aColorTable, /* ColorTable for world image */
Handle aPixelImage, /* Handle to pixel image for world */
short aRowBytes) /* Row bytes of pixel image */
{
GDHandle theSavedDevice;
GrafPtr theSavedPort;
Boolean theSavedAlloc;
/***
*** Check for a valid pixel depth
***/
if (aPixelDepth != 1 && aPixelDepth != 2 && aPixelDepth != 4 && aPixelDepth != 8)
return;
/***
*** Set worldDepth and worldBounds instance variables
***/
worldDepth = aPixelDepth;
worldBounds.left = aBoundsRect->left;
worldBounds.top = aBoundsRect->top;
worldBounds.right = aBoundsRect->right;
worldBounds.bottom = aBoundsRect->bottom;
/***
*** Create the world color table
***/
if (aColorTable != NULL) /* Copy the color table */
{
OSErr error;
theSavedAlloc = SetAllocation( kAllocCanFail);
error = HandToHand( &aColorTable);
SetAllocation( theSavedAlloc);
FailOSErr(error);
worldColors = aColorTable;
}
else /* Use standard color table for the pixel depth */
{
worldColors = GetCTable( aPixelDepth);
}
/***
*** Create the world pixel image
***/
if (aPixelImage != NULL && aRowBytes != 0) /* Use the existing pixel image */
{
HUnlock( aPixelImage);
worldPixels = aPixelImage;
worldOwnsPixels = FALSE; /* We don't own the pixel image */
}
else /* Create a new blank pixel image */
{
long width, height;
width = aBoundsRect->right - aBoundsRect->left;
height = aBoundsRect->bottom - aBoundsRect->top;
aRowBytes = ((width * aPixelDepth + 31) / 32 ) * 4;
theSavedAlloc = SetAllocation( kAllocCanFail);
aPixelImage = NewHandleClear( height * aRowBytes);
SetAllocation( theSavedAlloc);
FailNIL( aPixelImage);
worldPixels = aPixelImage;
worldOwnsPixels = TRUE; /* We own the pixel image, and must dispose of it */
}
/***
*** Create the offscreen graphics device
***/
worldDevice = NewGDevice( 0, -1L);
FailNIL( worldDevice);
HLock(worldDevice);
{
GDPtr gdev = *worldDevice;
gdev->gdID = 0;
gdev->gdType = clutType;
gdev->gdResPref = 4;
gdev->gdSearchProc = NULL;
gdev->gdCompProc = NULL;
gdev->gdFlags = (1<<gdDevType) | (1<<ramInit) | (1<<noDriver) | (1<<screenActive);
gdev->gdRect = *aBoundsRect;
HLock(gdev->gdPMap);
{
PixMapPtr pmap = *gdev->gdPMap;
pmap->baseAddr = NULL;
pmap->rowBytes = aRowBytes | 0x8000;
pmap->bounds = *aBoundsRect;
pmap->pixelSize = aPixelDepth;
pmap->cmpCount = 1;
pmap->cmpSize = aPixelDepth;
DisposCTable(pmap->pmTable);
pmap->pmTable = worldColors;
}
HUnlock(gdev->gdPMap);
}
HUnlock(worldDevice);
MakeITable( worldColors, (**worldDevice).gdITable, 4);
FailOSErr( QDError());
/***
*** Create the offscreen graphics port
***/
theSavedAlloc = SetAllocation( kAllocCanFail);
worldPort = (CGrafPtr) NewPtrClear( sizeof(CGrafPort));
SetAllocation( theSavedAlloc);
FailNIL( worldPort);
theSavedDevice = GetGDevice();
GetPort( &theSavedPort);
SetGDevice( worldDevice);
OpenCPort( worldPort);
worldPort->portRect = *aBoundsRect;
RectRgn( worldPort->visRgn, aBoundsRect);
RectRgn( worldPort->clipRgn, aBoundsRect);
SetGDevice( theSavedDevice);
SetPort( theSavedPort);
CView::ForceNextPrepare();
worldIsOK = TRUE;
}
/******************************************************************************
Dispose {OVERRIDE}
Dispose of a PixelWorld
******************************************************************************/
void CPixelWorld::Dispose()
{
if (worldPort != NULL)
{
ClosePort( worldPort); /* Close the color graphics port */
DisposPtr( worldPort); /* Dispose of color graphics port */
}
if (worldDevice != NULL)
{
DisposGDevice( worldDevice); /* Dispose of gDevice and colorTable */
}
else
{
DisposCTable( worldColors); /* Dispose of the colorTable */
}
if (worldPixels != NULL && worldOwnsPixels)
{
DisposHandle( worldPixels); /* Dispose of pixel image */
}
/* The inherited method disposes of black & white pixel worlds */
inherited::Dispose();
}
/******************************************************************************
WorldIsOK
Return TRUE if world has been initialized successfully, FALSE otherwise.
******************************************************************************/
Boolean CPixelWorld::WorldIsOK()
{
return( worldIsOK);
}
/******************************************************************************
GetBounds {OVERRIDE}
Return the bounding rectangle of a PixelWorld. This rectangle defines
the size and coordinate system of the PixelWorld.
******************************************************************************/
void CPixelWorld::GetBounds(
LongRect *theBounds)
{
*theBounds = worldBounds;
}
/******************************************************************************
SetBoundsOrigin {OVERRIDE}
Set the coordinates of the top left corner of the bounds of a
PixelWorld. This changes the coordinate system of the PixelWorld.
Note that the visRgn and clipRgn of the PixelWorld are reset.
******************************************************************************/
void CPixelWorld::SetBoundsOrigin(
short hOrigin,
short vOrigin)
{
Rect bounds;
if (!worldIsOK) return;
bounds.left = hOrigin;
bounds.top = vOrigin;
bounds.right = hOrigin + (worldBounds.right - worldBounds.left);
bounds.bottom = vOrigin + (worldBounds.bottom - worldBounds.top);
worldBounds.left = bounds.left;
worldBounds.top = bounds.top;
worldBounds.right = bounds.right;
worldBounds.bottom = bounds.bottom;
if (worldHasColor) /* World has color */
{
HLock(worldDevice);
{
GDPtr gdev = *worldDevice;
(**gdev->gdPMap).bounds = bounds;
gdev->gdRect = bounds;
}
HUnlock(worldDevice);
(**worldPort->portPixMap).bounds = bounds;
worldPort->portRect = bounds;
RectRgn( worldPort->visRgn, &bounds);
RectRgn( worldPort->clipRgn, &bounds);
}
else /* World is black and white */
{
macBitMap->bounds = bounds;
macPort->portBits.bounds = bounds;
macPort->portRect = bounds;
RectRgn( macPort->visRgn, &bounds);
RectRgn( macPort->clipRgn, &bounds);
}
}
/******************************************************************************
PixelIsBlack {OVERRIDE}
Determine whether the pixel at the specified coordinates is black.
Returns FALSE if the pixel is not black or it is not within the
world bounds rectangle.
******************************************************************************/
Boolean CPixelWorld::PixelIsBlack(
LongPt *pixelPos)
{
RGBColor color;
if (!worldIsOK) return (FALSE);
if (worldHasColor) /* World has color */
{
if (GetPixelColor( pixelPos, &color) == TRUE) /* Inside */
{
if (color.red == 0 && color.green == 0 && color.blue == 0)
return (TRUE);
else
return (FALSE);
}
else
{
return (TRUE); /* Pixel is outside and must be black */
}
}
else /* World is black and white */
{
return (inherited::PixelIsBlack(pixelPos));
}
}
/******************************************************************************
GetPixelColor
Determines the color of the pixel at the specified coordinates.
Returns FALSE if the point is not within the PixelWorld.
*** IMPORTANT ***
The offscreen pixel world must be active and the worldPixels
must be locked for this method to work properly. Therefore,
always send a BeginDrawing message before calling GetPixelColor().
When you are finished getting all the pixel colors you need,
then send the EndDrawing message to restore the previous
drawing environment.
******************************************************************************/
Boolean CPixelWorld::GetPixelColor(
LongPt *pixelPos,
RGBColor *color)
{
LongRect bounds = worldBounds;
if (!worldIsOK) return (FALSE);
if (!PtInLongRect( pixelPos, &bounds)) /* Pixel is OUTSIDE bounds rectangle */
return (FALSE);
if (worldHasColor) /* World has color */
{
if (worldPixelsLocked)
GetCPixel((short) pixelPos->h, (short) pixelPos->v, color); /* Get color */
else
color->red = color->green = color->blue = 0; /* Black */
}
else /* World is black and white */
{
if (inherited::PixelIsBlack(pixelPos))
color->red = color->green = color->blue = 0; /* Black */
else
color->red = color->green = color->blue = 65535; /* White */
}
return(TRUE); /* Pixel is INSIDE bounds rectangle */
}
/******************************************************************************
GetPixelDepth
Return the bounding rectangle of a PixelWorld. This rectangle defines
the size and coordinate system of the PixelWorld.
******************************************************************************/
short CPixelWorld::GetPixelDepth()
{
return (worldDepth);
}
/******************************************************************************
GetRowBytes
Return row byte length for the offscreen image.
******************************************************************************/
short CPixelWorld::GetRowBytes()
{
short rowBytes;
if (!worldIsOK) return (0);
if (worldHasColor) /* World has color */
{
rowBytes = (**worldPort->portPixMap).rowBytes;
}
else /* World is black and white */
{
rowBytes = macBitMap->rowBytes;
}
rowBytes &= 0x7FFF;
return (rowBytes);
}
/******************************************************************************
GetHandleToPixels
Return a handle to the pixel image. The handle is valid when the
offscreen world is in color but not when its a black and white CBitMap
world. If the image is a black and white, this function returns NULL.
******************************************************************************/
Handle CPixelWorld::GetHandleToPixels()
{
return( worldPixels);
}
/******************************************************************************
GetPointerToPixels
Return a pointer to the pixel image. Works for color and black/white
images as well.
******************************************************************************/
Ptr CPixelWorld::GetPointerToPixels()
{
if (!worldIsOK) return (NULL);
if (worldHasColor) /* World has color */
{
return( (Ptr) *worldPixels);
}
else /* World is black and white */
{
return( (Ptr) macBitMap->baseAddr);
}
}
/******************************************************************************
LockWorld
Lock or unlock the worldPixels handle according to the setLock flag.
If setLock is true, then the worldPixels handle is locked and the
de-referenced handle is put into the baseAddr field of worldDevice
and worldPort PixMap structures.
******************************************************************************/
Boolean CPixelWorld::LockWorld(
Boolean setLock)
{
if (!worldIsOK) return (FALSE);
if (worldHasColor)
{
if (worldPixelsLocked)
{
if (!setLock)
{
PixMapHandle hMap;
HUnlock(worldPixels);
hMap = (**worldDevice).gdPMap;
(**hMap).baseAddr = NULL;
hMap = worldPort->portPixMap;
(**hMap).baseAddr = NULL;
worldPixelsLocked = FALSE;
}
return (TRUE);
}
else
{
if (setLock)
{
PixMapHandle hMap;
MoveHHi(worldPixels);
HLock(worldPixels);
hMap = (**worldDevice).gdPMap;
(**hMap).baseAddr = (Ptr) *worldPixels;
hMap = worldPort->portPixMap;
(**hMap).baseAddr = (Ptr) *worldPixels;
worldPixelsLocked = TRUE;
}
return (FALSE);
}
}
return (FALSE);
}
/******************************************************************************
ActivateWorld
Activates the offscreen pixel world so that all drawing will take
place in the offscreen graphics port. The currently active graphics
device and port are saved so they can be restored later.
******************************************************************************/
void CPixelWorld::ActivateWorld()
{
if (!worldIsOK) return;
if (worldHasColor) /* World has color */
{
saveDevice = GetGDevice();
GetPort( &savePort);
LockWorld( TRUE);
SetGDevice( worldDevice);
SetPort( worldPort);
}
else /* World is black and white */
{
GetPort( &savePort);
SetPort( macPort);
}
}
/******************************************************************************
DeactivateWorld
Restores the previously active graphics device and port.
******************************************************************************/
void CPixelWorld::DeactivateWorld()
{
if (!worldIsOK) return;
if (worldHasColor) /* World has color */
{
LockWorld( FALSE);
if (saveDevice != NULL) SetGDevice( saveDevice);
if (savePort != NULL) SetPort( savePort);
saveDevice = NULL;
savePort = NULL;
}
else
{
if (savePort != NULL) SetPort( savePort);
savePort = NULL;
}
}
/******************************************************************************
CopyTo {OVERRIDE}
Copy bits to a PixelWorld from the bit map of the current port. The
fromRect is a rectangle in the current port's bit map (source rect),
and the toRect is a rectangle in this PixelWorld (dest rect). maskRgn is
a clipping region specified in the same coords as the dest rect,
i.e., the coords of this PixelWorld. A NULL maskRgn means that no extra
clipping is performed. Copying takes place using the transfer mode
stored in the xferMode instance variable.
******************************************************************************/
void CPixelWorld::CopyTo(
LongRect *fromRect,
LongRect *toRect,
RgnHandle maskRgn)
{
if (!worldIsOK) return;
if (worldHasColor) /* World has color */
{
Boolean savedLock;
savedLock = LockWorld( TRUE);
LCopyBits( &thePort->portBits, &((GrafPtr)worldPort)->portBits,
fromRect, toRect, xferMode, maskRgn);
LockWorld( savedLock);
}
else /* World is black and white */
{ /* Call the inherited method */
inherited::CopyTo( fromRect, toRect, maskRgn);
}
}
/******************************************************************************
CopyFrom {OVERRIDE}
Copy bits from a PixelWorld to the bit map of the current port. The
fromRect is a rectangle in this PixelWorld (source rect), and the
toRect is a rectangle in the current port's bit map (dest rect).
maskRgn is a clipping region specified in the same coords as the
dest rect, i.e., the coords of the current port. A NULL maskRgn means
that no extra clipping is performed. Copying takes place using the
transfer mode stored in the xferMode instance variable.
******************************************************************************/
void CPixelWorld::CopyFrom(
LongRect *fromRect,
LongRect *toRect,
RgnHandle maskRgn)
{
if (!worldIsOK) return;
if (worldHasColor) /* World has color */
{
Boolean savedLock;
savedLock = LockWorld( TRUE);
LCopyBits( &((GrafPtr)worldPort)->portBits, &thePort->portBits,
fromRect, toRect, xferMode, maskRgn);
LockWorld( savedLock);
}
else /* World is black and white */
{ /* Call the inherited method */
inherited::CopyFrom( fromRect, toRect, maskRgn);
}
}
/******************************************************************************
BeginDrawing {OVERRIDE}
Always end this message before performing any drawing to the
offscreen pixel world. This function saves the current GDevice
and GrafPort, activates the worldDevice and worldPort, and sends
a LockWorld(TRUE) message to lock down the pixel image.
If you do not call BeginDrawing() before drawing to the offscreen
world, the PixMaps of the worldDevice and worldPort will have NULL
baseAddr pointers and any drawing calls will probably cause a CRASH
since low memory addresses will be overwritten !!!!!!
******************************************************************************/
void CPixelWorld::BeginDrawing()
{
ActivateWorld();
}
/******************************************************************************
EndDrawing {OVERRIDE}
Always send this message after performing any drawing to the
offscreen pixel world. This function resets the port to the
way it was before the BeginDrawing message. It restores the
saved GDevice and GrafPort, and unlocks the pixel image.
******************************************************************************/
void CPixelWorld::EndDrawing()
{
DeactivateWorld();
}